package com.hailong.zyt.mapper;

import com.hailong.zyt.beans.Course;
import com.hailong.zyt.beans.CourseAll;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hailong
 * @since 2021-05-17
 */
public interface CourseAllMapper extends BaseMapper<CourseAll> {


    /*------------------------------------------------------------------------------------------------------*/
    /*
     * 根据ID查询该学生选了几门课程
     * */
    @Select("SELECT COUNT(cou_id) FROM course_all WHERE stu_id = #{stuId} GROUP BY stu_id")
    Integer selectCourseCount(@Param("stuId") Long stuId);

    /*
    * 根据学生ID查询所选课程的详细信息
    * */
    @Select("SELECT c.* " +
            "FROM course_all ca, course c " +
            "WHERE ca.stu_id = #{stuId} AND ca.cou_id = c.cou_id")
    List<Course> selectAllCourseById(@Param("stuId") Long stuId);
    /*------------------------------------------------------------------------------------------------------*/

    /*------------------------------------------------------------------------------------------------------*/

    /*------------------------------------------------------------------------------------------------------*/
}
